#include "protocol.h"
#include <stdlib.h>
// #include <unistd.h>
#include <string.h>
#include <QDebug>

PDU *makePDU(uint uiMsgLen)
{
    uint uiPDU_len = sizeof(PDU) + uiMsgLen;
    PDU* ret = (PDU*)malloc(uiPDU_len);
    if (ret == NULL) {
        exit(EXIT_FAILURE);
    }
    memset(ret, 0, uiPDU_len);
    ret->uiPDULen = uiPDU_len;
    ret->uiMsgLen = uiMsgLen;
    return ret;
}

void PDU::printPDU()
{
    /*
    uint uiPDULen;  //总的协议数据单元大小
    uint uiMsgType;
    char caData[64];
    uint uiMsgLen;  //实际消息长度
    int caMsg[];    //实际消息
*/
    qDebug() << "--------------------------------";
    qDebug() << "总的协议数据单元大小：" << uiPDULen << endl <<
        "协议数据单元类新：" << uiMsgType<< endl <<
        "caData：" << caData<< endl <<
        "实际消息长度：" << uiMsgLen<< endl <<
        "实际消息：" << (char*)caMsg;
    qDebug() << "--------------------------------";

}
